home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Color Picker SDK / Sample Code / Picker Demo Sample / TestPickerUtil.c < prev   
Encoding:
Text File  |  1997-06-13  |  15.4 KB  |  627 lines  |  [TEXT/CWIE]

  1. //===============================================================================
  2. //===============================================================================
  3. //
  4. //                                   TestPickerUtil.c
  5. //
  6. //                                  john calhoun 1997
  7. //
  8. //===============================================================================
  9. //===============================================================================
  10.  
  11.  
  12. #include <CMICCProfile.h>
  13. #include <ColorPicker.h>
  14. #include "TestPicker.h"
  15.  
  16.  
  17. #define MIN3(a,b,c)        ( ((a)<(b)) ? (((a)<(c))?(a):(c)) : (((b)<(c))?(b):(c)) )
  18. #define MAX3(a,b,c)        ( ((a)>(b)) ? (((a)>(c))?(a):(c)) : (((b)>(c))?(b):(c)) )
  19.  
  20. #define colorC            color->cmyk.cyan
  21. #define colorM            color->cmyk.magenta
  22. #define colorY            color->cmyk.yellow
  23. #define colorK            color->cmyk.black
  24. #define colorR            color->rgb.red
  25. #define colorG            color->rgb.green
  26. #define colorB            color->rgb.blue
  27.  
  28. enum
  29. {
  30.     cmICCReservedFlagsMask        = 0x0000FFFF,                    /* these bits of the flags field are defined and reserved by ICC */
  31.     cmEmbeddedMask                = 0x00000001,                    /* if bit 0 is 0 then not embedded profile, if 1 then embedded profile */
  32.     cmEmbeddedUseMask            = 0x00000002,                    /* if bit 1 is 0 then ok to use anywhere, if 1 then ok to use as embedded profile only */
  33.     cmCMSReservedFlagsMask        = 0xFFFF0000,                    /* these bits of the flags field are defined and reserved by CMS vendor */
  34.     cmQualityMask                = 0x00030000,                    /* if bits 16-17 is 0 then normal, if 1 then draft, if 2 then best */
  35.     cmInterpolationMask            = 0x00040000,                    /* if bit 18 is 0 then interpolation, if 1 then lookup only */
  36.     cmGamutCheckingMask            = 0x00080000                    /* if bit 19 is 0 then create gamut checking info, if 1 then no gamut checking info */
  37. };
  38.  
  39. struct CMConcatProfileSet3
  40. {
  41.     UInt16                     keyIndex;        // Zero-based.
  42.     UInt16                     count;            // Min 1.
  43.     CMProfileRef             profileSet[3];    // Ordered from Source -> Proof -> Dest
  44. };
  45. typedef struct CMConcatProfileSet3 CMConcatProfileSet3;
  46.  
  47.  
  48. long GetColorSyncVersion (void);
  49.  
  50.  
  51. //===================================================================== Functions
  52. //--------------------------------------------------------------------- InitToolbox
  53.  
  54. void InitToolbox (void)
  55. {
  56.     MoreMasters();
  57.     MaxApplZone();
  58.     InitGraf(&qd.thePort);
  59.     InitFonts();
  60.     InitWindows();
  61.     InitMenus();
  62.     TEInit();
  63.     InitDialogs(nil);
  64.     FlushEvents (everyEvent, 0);
  65.     InitCursor();
  66.     
  67.     GetDateTime((unsigned long *)&qd.randSeed);
  68. }
  69.  
  70. //--------------------------------------------------------------  WhatsOurDepth  
  71.  
  72. short WhatsOurDepth (void)
  73. {
  74.     GDHandle        thisDevice;
  75.     short            thisDepth;
  76.     char            wasState;
  77.     
  78.     thisDepth = 0;
  79.     thisDevice = GetMainDevice();
  80.     
  81.     if (thisDevice)
  82.     {
  83.         wasState = HGetState((Handle)thisDevice);
  84.         HLock((Handle)thisDevice);
  85.         thisDepth = (**(**thisDevice).gdPMap).pixelSize;
  86.         HSetState((Handle)thisDevice, wasState);
  87.     }
  88.     
  89.     return (thisDepth);
  90. }
  91.  
  92.  
  93. //--------------------------------------------------------------------- RandomInt
  94.  
  95. short RandomInt (short range)
  96. {
  97.     register long    rawResult;
  98.     
  99.     rawResult = Random();    
  100.     if (rawResult < 0)
  101.         rawResult = -rawResult;
  102.     return ((rawResult * (long)range) >> 15);
  103. }
  104.  
  105. //--------------------------------------------------------------------- OpenSimpleWindow
  106.  
  107. void OpenSimpleWindow (void)
  108. {
  109.     SetRect(&windowBounds, 0, 0, 608, 420);
  110.     simpleWindow = (WindowRef)NewCWindow(nil, &windowBounds, "\pColor Picker Demo", 
  111.             true, noGrowDocProc, 
  112.             (GrafPort *)(-1L), false, 0L);
  113.     
  114.     MoveWindow(simpleWindow, 16, 40, true);
  115.     
  116.     SetPort(simpleWindow);
  117. }
  118.  
  119. //--------------------------------------------------------------------- AddMenusToMenuBar
  120.  
  121. void AddMenusToMenuBar (void)
  122. {
  123.     appleMenu = GetMenu(128);
  124.     AppendResMenu(appleMenu, 'DRVR');
  125.     InsertMenu(appleMenu, 0);
  126.     
  127.     fileMenu = GetMenu(129);
  128.     InsertMenu(fileMenu, 0);
  129.     
  130.     editMenu = GetMenu(130);
  131.     InsertMenu(editMenu, 0);
  132.     
  133.     testMenu = GetMenu(131);
  134.     InsertMenu(testMenu, 0);
  135.     
  136.     DrawMenuBar();
  137. }
  138.  
  139. //--------------------------------------------------------------------- DebugNum
  140.  
  141. void DebugNum (long theNum)
  142. {
  143.     Str255        tempStr;
  144.     
  145.     NumToString(theNum, tempStr);
  146.     DebugStr(tempStr);
  147. }
  148.  
  149. //--------------------------------------------------------------  PasStringCopy
  150.  
  151. // Given a source string and storage for a second, this function…
  152. // copies from one to the other.  It assumes Pascal style strings.
  153.  
  154. void PasStringCopy (StringPtr p1, StringPtr p2)
  155. {
  156.     register short        stringLength;
  157.     
  158.     stringLength = *p2++ = *p1++;
  159.     while (--stringLength >= 0)
  160.         *p2++ = *p1++;
  161. }
  162.  
  163. //--------------------------------------------------------------  PasStringConcat
  164. // This function concatenates the second Pascal string to the end of…
  165. // the first Pascal string.
  166.  
  167. void PasStringConcat (StringPtr p1, StringPtr p2)
  168. {
  169.     short        wasLength, addedLength, i;
  170.     
  171.     wasLength = *p1;
  172.     if (wasLength > 255)
  173.         wasLength = 255;
  174.     
  175.     addedLength = *p2;
  176.     if ((wasLength + addedLength) > 255)
  177.         addedLength = 255 - wasLength;
  178.     
  179.     *p1 = wasLength + addedLength;
  180.     
  181.     *p1++;
  182.     *p2++;
  183.     
  184.     for (i = 0; i < wasLength; i++)
  185.         *p1++;
  186.     
  187.     for (i = 0; i < addedLength; i++)
  188.         *p1++ = *p2++;
  189. }
  190.  
  191. //--------------------------------------------------------------------- AllocateVennColorDiagramRegions
  192.  
  193. void AllocateVennColorDiagramRegions (void)
  194. {
  195.     #define        kOvalDiameter        80
  196.     #define        kOvalLeft            52
  197.     #define        kOvalTop            260
  198.     #define        kCircleHOffset        23
  199.     #define        kCircleVOffset        40
  200.     Rect        tempOval, tempRect;
  201.     RgnHandle    tempR, tempG, tempB;
  202.     
  203.     wholeVenn = NewRgn();
  204.     regionR = NewRgn();
  205.     regionG = NewRgn();
  206.     regionB = NewRgn();
  207.     regionRG = NewRgn();
  208.     regionGB = NewRgn();
  209.     regionBR = NewRgn();
  210.     regionRGB = NewRgn();
  211.     tempR = NewRgn();
  212.     tempG = NewRgn();
  213.     tempB = NewRgn();
  214.     blackRgn = NewRgn();
  215.     
  216.     if (!wholeVenn || !regionR || !regionG || !regionB || !regionRG || !blackRgn || 
  217.             !regionGB || !regionBR || !regionRGB || !tempR || !tempG || !tempB)
  218.         return;
  219.     
  220.                 // Create RED circle.
  221.     SetRect(&tempOval, 0, 0, kOvalDiameter, kOvalDiameter);
  222.     OffsetRect(&tempOval, kOvalLeft, kOvalTop);
  223.     OpenRgn();
  224.     FrameOval(&tempOval);
  225.     CloseRgn(regionR);
  226.     
  227.                 // Create GREEN circle.
  228.     SetRect(&tempOval, 0, 0, kOvalDiameter, kOvalDiameter);
  229.     OffsetRect(&tempOval, kOvalLeft, kOvalTop);
  230.     OffsetRect(&tempOval, -kCircleHOffset, kCircleVOffset);
  231.     OpenRgn();
  232.     FrameOval(&tempOval);
  233.     CloseRgn(regionG);
  234.     
  235.                 // Create BLUE circle.
  236.     SetRect(&tempOval, 0, 0, kOvalDiameter, kOvalDiameter);
  237.     OffsetRect(&tempOval, kOvalLeft, kOvalTop);
  238.     OffsetRect(&tempOval, kCircleHOffset, kCircleVOffset);
  239.     OpenRgn();
  240.     FrameOval(&tempOval);
  241.     CloseRgn(regionB);
  242.     
  243.     CopyRgn(regionR, tempR);
  244.     CopyRgn(regionG, tempG);
  245.     CopyRgn(regionB, tempB);
  246.     
  247.                 // Create whole region.
  248.     UnionRgn(regionR, regionG, wholeVenn);
  249.     UnionRgn(wholeVenn, regionB, wholeVenn);
  250.     
  251.                 // Create 2-color intersections.
  252.     SectRgn(regionR, regionG, regionRG);
  253.     DiffRgn(regionRG, regionB, regionRG);
  254.     
  255.     SectRgn(regionG, regionB, regionGB);
  256.     DiffRgn(regionGB, regionR, regionGB);
  257.     
  258.     SectRgn(regionB, regionR, regionBR);
  259.     DiffRgn(regionBR, regionG, regionBR);
  260.     
  261.                 // Create 3-color intersection.
  262.     SectRgn(regionR, regionG, regionRGB);
  263.     SectRgn(regionRGB, regionB, regionRGB);
  264.     
  265.                 // Finally, clip original R, G, and B regions.
  266.     DiffRgn(regionR, tempG, regionR);
  267.     DiffRgn(regionR, tempB, regionR);
  268.     
  269.     DiffRgn(regionG, tempR, regionG);
  270.     DiffRgn(regionG, tempB, regionG);
  271.     
  272.     DiffRgn(regionB, tempG, regionB);
  273.     DiffRgn(regionB, tempR, regionB);
  274.     
  275.     DisposeRgn(tempR);
  276.     DisposeRgn(tempG);
  277.     DisposeRgn(tempB);
  278.     
  279.                 // Create black region.
  280.     tempRect.left = 16;
  281.     tempRect.top = 240;
  282.     tempRect.right = tempRect.left + 154;
  283.     tempRect.bottom = 400;
  284.     RectRgn(blackRgn, &tempRect);
  285.     DiffRgn(blackRgn, wholeVenn, blackRgn);
  286. }
  287.  
  288. //--------------------------------------------------------------------- SetUpCMYKRects
  289.  
  290. void SetUpCMYKRects (void)
  291. {
  292.     #define        kCMYKTop        50
  293.     #define        kCMYKBottom        80
  294.     #define        kCMYKWide        60
  295.     #define        kCLeft            311
  296.     #define        kMLeft            kCLeft + kCMYKWide + 16
  297.     #define        kYLeft            kMLeft + kCMYKWide + 16
  298.     #define        kKLeft            kYLeft + kCMYKWide + 16
  299.     
  300.     SetRect(&rectC, kCLeft, kCMYKTop, kCLeft + kCMYKWide, kCMYKBottom);
  301.     SetRect(&rectM, kMLeft, kCMYKTop, kMLeft + kCMYKWide, kCMYKBottom);
  302.     SetRect(&rectY, kYLeft, kCMYKTop, kYLeft + kCMYKWide, kCMYKBottom);
  303.     SetRect(&rectK, kKLeft, kCMYKTop, kKLeft + kCMYKWide, kCMYKBottom);
  304. }
  305.  
  306. //--------------------------------------------------------------------- SetUpBounceLine
  307.  
  308. void SetUpBounceLine (void)
  309. {
  310.     Rect        gWorldBounds;
  311.     GDHandle    wasWorld;
  312.     CGrafPtr    wasCPort;
  313.     OSErr        theErr;
  314.     
  315.     SetRect(&bounceRect, 0, 0, 581, 560);
  316.     OffsetRect(&bounceRect, 76, 240);
  317.     
  318.     x1 = RandomInt(bounceRect.right - bounceRect.left) + bounceRect.left;
  319.     x2 = RandomInt(bounceRect.right - bounceRect.left) + bounceRect.left;
  320.     
  321.     y1 = RandomInt(bounceRect.bottom - bounceRect.top) + bounceRect.top;
  322.     y2 = RandomInt(bounceRect.bottom - bounceRect.top) + bounceRect.top;
  323.     
  324.     deltaX1 = RandomInt(10) + 6;
  325.     deltaY1 = RandomInt(10) + 6;
  326.     deltaX2 = RandomInt(10) + 6;
  327.     deltaY2 = RandomInt(10) + 6;
  328.     
  329.     wasTicks = TickCount();
  330.     
  331.                 // Create GWorld.
  332.     gWorldBounds.left = bounceRect.left >> 2;
  333.     gWorldBounds.top = bounceRect.top >> 2;
  334.     gWorldBounds.right = (bounceRect.right >> 2) + kLineThick;
  335.     gWorldBounds.bottom = (bounceRect.bottom >> 2) + kLineThick;
  336.     OffsetRect(&gWorldBounds, -gWorldBounds.left, -gWorldBounds.top);
  337.     GetGWorld(&wasCPort, &wasWorld);
  338.     theErr = NewGWorld(&theGWorld, 32, &gWorldBounds, nil, nil, useTempMem);
  339.     if (theErr != noErr)
  340.     {
  341.         theGWorld = 0L;
  342.         goto bail;
  343.     }
  344.     LockPixels(GetGWorldPixMap(theGWorld));
  345.     SetGWorld(theGWorld, 0L);
  346.     ForeColor(blackColor);
  347.     BackColor(whiteColor);
  348.     PaintRect(&gWorldBounds);
  349.     PenSize(kLineThick, kLineThick);
  350.     UnlockPixels(GetGWorldPixMap(theGWorld));
  351.     SetGWorld(wasCPort, wasWorld);
  352.     
  353. bail:
  354.     
  355.     return;
  356. }
  357.  
  358. //---------------------------------------------------------------------  PickerMatchColors
  359.  
  360. void PickerMatchColors (PickerCWPtr cw, CMColor *myColors, unsigned long count)
  361. {
  362.     CMError        theErr;
  363.     
  364.     theErr = noErr;
  365.     
  366.     if (!cw->matchingNeeded)
  367.         goto bail;
  368.     
  369.     if (cw->cw)
  370.     {
  371.         PickerMatchColorsSimple(myColors, count, cw->srcSpace, cw->srcProfSpace);
  372.         
  373.         theErr = CWMatchColors(cw->cw, myColors, count);
  374.         if (theErr != noErr)
  375.             goto bail;
  376.         
  377.         if (cw->cw2)
  378.         {
  379.             theErr = CWMatchColors(cw->cw2, myColors, count);
  380.             if (theErr != noErr)
  381.                 goto bail;
  382.         }
  383.         
  384.         PickerMatchColorsSimple(myColors, count, cw->dstProfSpace, cw->dstSpace);
  385.     }
  386.     else
  387.         PickerMatchColorsSimple(myColors, count, cw->srcSpace, cw->dstSpace);
  388.     
  389. bail:
  390.     
  391.     return;
  392. }
  393.  
  394. //--------------------------------------------------------------------- PickerMatchColorsSimple
  395.  
  396. void PickerMatchColorsSimple (CMColor *myColors, unsigned long count, 
  397.         OSType srcSpace, OSType dstSpace)
  398. {
  399.             // Try to match it ourselves.
  400.     CMColor        *color;
  401.     
  402.     if ( srcSpace==dstSpace )
  403.         return;
  404.     
  405.     if ( srcSpace==cmRGBData && dstSpace==cmCMYKData )
  406.     {
  407.         for ( color=myColors; count>0; count--, color++)
  408.         {
  409.             colorK = (0xFFFF - MAX3(colorR, colorG, colorB));
  410.             colorC = (0xFFFF - colorR) - colorK;
  411.             colorM = (0xFFFF - colorG) - colorK;
  412.             colorY = (0xFFFF - colorB) - colorK;
  413.         }
  414.     }
  415.     else if ( srcSpace==cmCMYKData && dstSpace==cmRGBData )
  416.     {
  417.         for ( color=myColors; count>0; count--, color++)
  418.         {
  419.             colorR = 0xFFFF - colorC;
  420.             colorG = 0xFFFF - colorM;
  421.             colorB = 0xFFFF - colorY;
  422.             
  423.             colorR = (colorR > colorK ) ? (colorR - colorK) : (0);
  424.             colorG = (colorG > colorK ) ? (colorG - colorK) : (0);
  425.             colorB = (colorB > colorK ) ? (colorB - colorK) : (0);
  426.         }
  427.     }
  428.     
  429.     return;
  430. }
  431.  
  432. //---------------------------------------------------------------------  GetColorSyncVersion
  433.  
  434. long GetColorSyncVersion (void)
  435. {
  436.     long            colorSyncLong;
  437.  
  438.     if ( Gestalt(gestaltColorMatchingVersion, &colorSyncLong)==noErr )
  439.         return colorSyncLong;
  440.     else
  441.         return 0L;
  442. }
  443.  
  444. //---------------------------------------------------------------------  GetProfileColorSpace
  445.  
  446. OSType GetProfileColorSpace (CMProfileRef prof)
  447. {
  448.     CMAppleProfileHeader    header;
  449.     OSType                    space;
  450.     CMError                    theErr;
  451.     
  452.     space = cmRGBData;
  453.     
  454.     if (prof)
  455.     {
  456.         if (GetColorSyncVersion() >= gestaltColorSync20)
  457.         {
  458.             theErr = CMGetProfileHeader(prof, &header);
  459.             if (theErr != noErr)
  460.                 goto bail;
  461.             
  462.             space = header.cm2.dataColorSpace;
  463.         }
  464.     }
  465.     
  466. bail:
  467.     
  468.     return space;
  469. }
  470.  
  471. //---------------------------------------------------------------------  PickerNewColorWorld
  472.  
  473. OSErr NPickerNewColorWorld (PickerCWPtr cw, CMProfileRef src, CMProfileRef prf, 
  474.         CMProfileRef dst, OSType srcSpace, OSType dstSpace)
  475. {
  476.     CMError            theErr;
  477.     CMProfileRef    systemProfile;
  478.     CMAppleProfileHeader header;
  479.     Boolean            srcHeaderWasChanged;
  480.     long            csVersion;
  481.     
  482.     theErr = noErr;
  483.     systemProfile = nil;
  484.     cw->cw = nil;
  485.     cw->cw2 = nil;
  486.     cw->matchingNeeded = !(srcSpace == dstSpace);
  487.     
  488.                 // Remember the spaces.
  489.     cw->srcSpace = (srcSpace)?(srcSpace):(cmRGBData);
  490.     cw->dstSpace = (dstSpace)?(dstSpace):(cmRGBData);
  491.     cw->srcProfSpace = cw->srcSpace;
  492.     cw->dstProfSpace = cw->dstSpace;
  493.     cw->prfProfSpace = GetProfileColorSpace(prf);
  494.     
  495.                 // First make sure that ColorSync2 is around.
  496.     csVersion = GetColorSyncVersion() ;
  497.     if (csVersion < gestaltColorSync20)
  498.     {
  499.         theErr = colorSyncNotInstalled;
  500.         if (theErr == noErr)
  501.             goto bail;
  502.     }
  503.     
  504.                 // if no-op match, bail
  505.     if (src==0L && prf==0L && dst==0L)
  506.         goto bail;
  507.     
  508.                 // Derive from system prof
  509.     if (dst == 0L)
  510.     {
  511.         if (!systemProfile)
  512.             (void) CMGetSystemProfile(&systemProfile) ;
  513.         dst = systemProfile;
  514.         cw->dstProfSpace = cmRGBData;
  515.         cw->matchingNeeded = true;
  516.     }
  517.     if (src == 0L)
  518.     {
  519.         if (!systemProfile)
  520.             (void) CMGetSystemProfile(&systemProfile) ;
  521.         src = systemProfile;
  522.         cw->srcProfSpace = cmRGBData;
  523.         cw->matchingNeeded = true;
  524.     }
  525.     
  526.                 // Set the noGamut-bit
  527.     if ( src && csVersion > gestaltColorSync20)
  528.     {
  529.         if (CMGetProfileHeader(src, &header) == noErr)
  530.         {
  531.             header.cm2.flags &= cmGamutCheckingMask;
  532.             (void) CMSetProfileHeader(src, &header);
  533.             srcHeaderWasChanged = true;
  534.         }
  535.     }
  536.     
  537.                 // Use ColorSync to make the color world.
  538.     if (prf == 0L)
  539.     {
  540.         theErr = NCWNewColorWorld(&(cw->cw), src, dst);
  541.         if (theErr == noErr)
  542.             goto bail;
  543.         
  544.         cw->matchingNeeded = true;
  545.     }
  546.     else
  547.     {
  548.         CMConcatProfileSet3        concat;
  549.         
  550.         concat.keyIndex = 1;
  551.         concat.count = 3;
  552.         concat.profileSet[0]= src;
  553.         concat.profileSet[1]= prf;
  554.         concat.profileSet[2]= dst;
  555.  
  556.         theErr = CWConcatColorWorld(&(cw->cw), (CMConcatProfileSet*)&concat);
  557.         
  558.                 // the above will generate an error
  559.                 // if any one of the profiles is a 1.0 profile
  560.         if (theErr)
  561.         {
  562.             theErr = NCWNewColorWorld(&(cw->cw), src, prf);
  563.             if (theErr == noErr)
  564.                 goto bail;
  565.             
  566.             theErr = NCWNewColorWorld(&(cw->cw2), prf, dst);
  567.             if (theErr == noErr)
  568.                 goto bail;
  569.         }
  570.         
  571.         if (systemProfile)
  572.             (void) CMCloseProfile(systemProfile);
  573.         
  574.         cw->matchingNeeded = true;
  575.     }
  576.     
  577. bail:
  578.                 // Us-set the noGamut-bit
  579.     if ( srcHeaderWasChanged && src!=systemProfile )
  580.     {
  581.         header.cm2.flags -= cmGamutCheckingMask;
  582.         (void) CMSetProfileHeader(src, &header);
  583.     }
  584.     
  585.                 // Dispose of derived profiles
  586.     if (systemProfile) (void) CMCloseProfile(systemProfile);
  587.     
  588.     if (theErr)
  589.         PickerDisposeColorWorld(cw);
  590.     
  591.     return theErr;
  592. }
  593.  
  594. //---------------------------------------------------------------------  PickerDisposeColorWorld
  595.  
  596. void PickerDisposeColorWorld (PickerCWPtr cw)
  597. {
  598.     if (cw->cw)
  599.         CWDisposeColorWorld(cw->cw);
  600.     
  601.     if (cw->cw2)
  602.         CWDisposeColorWorld(cw->cw2);
  603.     
  604.     cw->cw = 0;
  605.     cw->cw2 = 0;
  606.     cw->srcSpace = cw->dstSpace = 0L;
  607.     cw->srcProfSpace = cw->prfProfSpace = cw->dstProfSpace = 0L;
  608.     cw->matchingNeeded = false;
  609. }
  610.  
  611. //--------------------------------------------------------------------- OpenProfileHandle
  612.  
  613. CMError OpenProfileHandle (CMProfileRef *profReference, Handle profHandle, 
  614.         UInt32 flags, UInt32 intent)
  615. {
  616.     CMProfileLocation    profLocation;
  617.     
  618.     profLocation.locType = cmHandleBasedProfile;
  619.     profLocation.u.handleLoc.h = profHandle;
  620.     
  621.     (**(CM2Header **)profHandle).flags = flags;
  622.     (**(CM2Header **)profHandle).renderingIntent = intent;
  623.     
  624.     return CMOpenProfile(profReference, &profLocation);
  625. }
  626.  
  627.